<!-- 删除模态 -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalTitle" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="关闭"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="deleteModalTitle">警告</h4>
      </div>
      <div class="modal-body">
        <h4 class="text-center">您确定要删除该推荐？</h4>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button ng-disabled="transmitting" ng-click="deleteFeature()" type="button" class="btn btn-danger">确认删除</button>
      </div>
    </div>
  </div>
</div>

<!-- 主体 -->
<div ui-view class="view">
  <div class="page-header">
    <ol class="heading">
      <li><a ui-sref="main.features">推荐管理</a></li>
    </ol>
  </div>
  <div ng-if="noFeatureModel">
    <br><br><br>
    <h4 class="text-center text-muted">尚未添加推荐模型，请前往“系统设置”中添加</h4>
  </div>
  <div ng-repeat="model in models | orderBy: 'mixed.sort'" class="panel panel-default">
    <div class="panel-heading">{{model.name}}<small ng-if="model.description" class="text-muted pull-right">{{model.description}}</small></div>
    <div class="panel-body table-responsive">
      <table class="table table-hover">
        <thead class="text-center">
          <tr>
            <th>排序</th>
            <th ng-if="model.system.thumbnail">缩略图</th>
            <th>标题</th>
            <th ng-if="model.system.url">链接</th>
            <th ng-repeat="item in model.extensions">{{item.name}}</th>
            <th ng-if="editAuth" class="text-center">操作</th>
          </tr>
        </thead>
        <tbody class="text-center text-middle">
          <tr ng-repeat="feature in model.features | orderBy: 'sort'">
            <td>{{feature.sort}}</td>
            <td ng-if="model.system.thumbnail" width="90">
              <div ng-if="feature.thumbnail" class="list-thumbnail"><img ng-src="{{feature.thumbnail.src}}"></div>
              <div ng-if="!feature.thumbnail">-</div>
            </td>
            <td>{{feature.title | words: 20}}</td>
            <td ng-if="model.system.url">{{!feature.url ? '-' : feature.url | words: 20}}</td>
            <td ng-repeat="item in model.extensions">
              <span ng-if="!feature.extensions[item.key]">-</span>
              <span ng-if="feature.extensions[item.key] && item.type === 'media'">{{feature.extensions[item.key].length}} 个媒体</span>
              <span ng-if="feature.extensions[item.key] && item.type !== 'media'">{{feature.extensions[item.key] | words: 20}}</span>
            </td>
            <td ng-if="editAuth">
              <a ng-disabled="transmitting" ng-click="transmitting ? $event.preventDefault() : false" ui-sref="main.features.update({ model: model._id, feature: feature._id })" class="btn btn-default btn-xs"><i class="fa fa-edit"></i> 修改</a>
              <button ng-disabled="transmitting" ng-click="$parent.$parent.$parent.$parent.deleteFeatureInfo = { modelId: model._id, featureId: feature._id }" class="btn btn-default btn-xs" type="button" data-toggle="modal" data-target="#deleteModal"><i class="fa fa-trash-o"></i> 删除</button>
            </td>
          </tr>
        </tbody>
      </table>
      <br ng-if="editAuth">
      <button ng-if="editAuth && model.features.length < model.mixed.limit" ui-sref="main.features.create({ model: model._id })" class="btn btn-default btn-sm btn-block" type="button"><i class="fa fa-plus"></i> 新增推荐</button>
    </div>
  </div>
</div>